home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 4
/
FM Towns Free Software Collection 4 - Disc 1.iso
/
msdos
/
mcpr
/
cprfrmsb.asm
< prev
next >
Wrap
Assembly Source File
|
1991-10-18
|
11KB
|
789 lines
page 95,132
;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
;§ §
;§ マルチカラム コンパクト プリント ユーティリティ §
;§ §
;§ Multicolumn Compact PRint utility MCPR.EXE Ver1.40 §
;§ ~ ~ ~~ §
;§ Copyright (C) by 福地 邦雄 1989-1990. All rights reserved. §
;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
public newfile
public getchar
public ungetchar
public setlinumber
public fillineproc
public filgapproc
public initvaliable
public initpgbuff
public reducepagebuff
public hdrpgupdate
public fhandle
public pageproc
public asmpage
public baspage
public cpage
extrn inttoasc0:near
extrn inttoascs:near
extrn asctoint:near
extrn abort:near
;
YES equ 1
NO equ 0
EXT equ 3
;
data segment para public 'DATA'
;
extrn pgbuf:dword
extrn pgbufseg:word
extrn pgbufsiz:word
extrn gapsize:word
extrn linsiz:word
extrn clmcnt:word
extrn lincnt:word
extrn linptr:dword
extrn curclm:word
extrn curlin:word
extrn curblk:word
extrn curpage:word
extrn inline:word
extrn linumb:word
extrn numclm:word
extrn pgwidth:word
extrn pgtype:word
extrn linumber:word
extrn printend:word
extrn marginleft:word
extrn marginhead:word
extrn hdrprint:word
extrn numsepchar:byte
extrn filebuf:dword
extrn filebufoff:word
extrn errorno:word
extrn header:dword
extrn nameptr:dword
extrn hdrpgnum:word
extrn hdrlinoff:word
extrn hdrlinseg:word
extrn hdrln2seg:word
;
fhandle dw ?
eofflag dw ?
readsize dw ?
;
deftitle dw NO
feedflag dw NO
pageproc dw nopage
;
db '00000'
numsetarea db '00000'
;
freadmsg db 'file read error',0dh,0ah
frdmsgsiz equ $-freadmsg
;
ptmtitle db 'Print Time '
ptmttlsz equ $-ptmtitle
;
data ends
;
code segment para public 'CODE'
assume cs:code,ds:data
;
newfile proc
;
mov fhandle,ax
xor ax,ax
mov eofflag,ax
mov readsize,ax
mov filebufoff,ax
ret
;
newfile endp
;
getchar proc
;
push es
push di
push dx
xor ax,ax
cmp eofflag,YES
je short eofstatus
;
les di,filebuf
cmp di,readsize
jb existdata
call readfile
xor ax,ax
existdata:
mov al,es:[di]
inc filebufoff
cmp al,1ah
jne getcharend
mov eofflag,YES
eofstatus:
dec ah
getcharend:
test ah,ah
pop dx
pop di
pop es
ret
;
getchar endp
;
readfile proc
;
mov bx,fhandle
mov cx,8192
xor dx,dx
mov di,dx
mov filebufoff,di
push ds
mov ax,es
mov ds,ax
mov ah,3fh
int 21h
pop ds
jc readerr
mov readsize,ax
test ax,ax
jz readeof
ret
readeof:
mov byte ptr es:[di],1ah
ret
readerr:
mov errorno,ax
mov dx,offset freadmsg
mov cx,frdmsgsiz
jmp abort
;
readfile endp
;
ungetchar proc
;
dec filebufoff
ret
;
ungetchar endp
;
setlinumber proc
;
push ax
mov di,curlin
shl di,1
shl di,1
les di,[di+offset linptr]
cmp linumb,YES
jne linumend
cmp curclm,0
jne linumend
cmp inline,YES
je nosetlinum
mov inline,YES
mov ax,linumber
mov si,di
push es
push ds
pop es
mov di,offset numsetarea
call inttoasc0
xchg si,di
mov cx,numclm
sub si,cx
pop es
rep movsb
mov al,numsepchar
stosb
jmp short linumend
nosetlinum:
mov al,' '
mov cx,numclm
inc cx
rep stosb
linumend:
pop ax
ret
;
setlinumber endp
;
fillineproc proc
;
mov cx,clmcnt
sub cx,curclm
mov al,' '
rep stosb
mov bx,curlin
shl bx,1
shl bx,1
mov [bx+offset linptr],di
ret
;
fillineproc endp
;
filgapproc proc
;
mov dx,gapsize
test dx,dx
jz nogapsize
mov dh,byte ptr lincnt
mov bx,offset linptr
xor cx,cx
mov al,' '
setgaploop:
mov cl,dl
les di,[bx]
rep stosb
mov [bx],di
lea bx,[bx+4]
dec dh
jnz setgaploop
nogapsize:
ret
;
filgapproc endp
;
initvaliable proc
;
mov linumber,0
mov curpage,1
mov printend,NO
mov feedflag,NO
mov ax,linsiz
mov cl,4
shr ax,cl
mov bx,offset linptr
mov cx,lincnt
xor dx,dx
mov si,pgbufseg
bufptrloop:
mov [bx],dx
mov [bx+2],si
add si,ax
lea bx,[bx+4]
loop bufptrloop
;
cmp pgtype,EXT
je pgtypechk
jmp short sethdr
pgtypechk:
les di,nameptr
les di,es:[di]
xor ax,ax
mov cx,-1
repne scasb
cmp word ptr es:[di-3],'MS'
jne pgtypea1
cmp word ptr es:[di-5],'A.'
je pgtypeas
pgtypea1:
cmp word ptr es:[di-3],'CA'
jne pgtypea2
cmp word ptr es:[di-5],'M.'
je pgtypeas
pgtypea2:
cmp word ptr es:[di-3],'CN'
jne pgtypeb
cmp word ptr es:[di-5],'I.'
jne pgtypeb
pgtypeas:
mov pageproc,offset asmpage
jmp short sethdr
pgtypeb:
cmp word ptr es:[di-3],'SA'
jne pgtypec
cmp word ptr es:[di-5],'B.'
jne pgtypec
mov pageproc,offset baspage
jmp short sethdr
pgtypec:
mov pageproc,offset cpage
sethdr:
cmp hdrprint,YES
je headprt
noheadsiz:
mov hdrprint,NO
ret
headprt:
cld
mov al,' '
mov cx,pgwidth
cmp cx,12
jb noheadsiz
mov hdrlinoff,cx
mov hdrpgnum,cx
sub hdrpgnum,5
xor di,di
mov es,hdrlinseg
rep stosb
sub di,5
mov ax,curpage
call inttoasc0
mov word ptr es:[di-10],'aP'
mov word ptr es:[di-08],'eg'
mov word ptr es:[di-06],'- '
mov byte ptr es:[di-04],' '
mov deftitle,YES
xor ax,ax
mov cx,-1
les di,header
cmp byte ptr es:[di],0
jne titlexist
mov deftitle,NO
les di,nameptr
les di,es:[di]
titlexist:
mov si,di
repne scasb
not cx
dec cx
mov ax,pgwidth
sub ax,12
cmp cx,ax
jbe fitstring
mov cx,ax
fitstring:
push ds
push es
mov di,marginleft
mov es,hdrlinseg
pop ds
rep movsb
pop ds
mov al,20h
stosb
;
cmp deftitle,YES
jne putfstat
jmp nofname
putfstat:
mov ax,4202h
mov bx,fhandle
xor cx,cx
mov dx,cx
int 21h
;
mov cx,10000
div cx
test ax,ax
jz less10k
call inttoascs
less10k:
mov ax,dx
call inttoascs
mov word ptr es:[di],'yB'
mov word ptr es:[di+2],'et'
mov byte ptr es:[di+4],'s'
lea di,[di+6]
;
mov ax,4200h
mov bx,fhandle
xor cx,cx
mov dx,cx
int 21h
;
mov ax,5700h
mov bx,fhandle
int 21h
;
shr cx,1
shr cx,1
shr cx,1
shr cl,1
shr cl,1
mov si,cx
;
mov ax,dx
and dx,01fh
shr ax,1
mov cl,4
shr al,cl
xchg dh,al
xchg ah,al
add ax,1980
call timestamp
nofname:
mov di,pgwidth
sub di,39
jb initend
mov si,offset ptmtitle
mov cx,ptmttlsz
rep movsb
;
mov ah,2ch
int 21h
mov si,cx
mov ah,2ah
int 21h
mov ax,cx
call timestamp
initend:
ret
;
initvaliable endp
;
initpgbuff proc
;
xor ax,ax
mov curclm,ax
mov curlin,ax
mov curblk,ax
mov cx,pgbufsiz
les di,pgbuf
rep stosw
mov ax,marginleft
mov bx,offset linptr
mov cx,lincnt
setoffloop:
mov [bx],ax
lea bx,[bx+4]
loop setoffloop
;
test ax,ax
jz initbuffend
push dx
push si
push di
mov si,ax
mov bx,offset linptr+2
mov dx,lincnt
mov al,' '
setmrgnloop:
mov es,[bx]
xor di,di
mov cx,si
rep stosb
lea bx,[bx+4]
dec dx
jnz setmrgnloop
pop di
pop si
pop dx
initbuffend:
ret
;
initpgbuff endp
;
reducepagebuff proc
;
std
mov al,' '
mov bx,offset linptr
mov cx,lincnt
mov curlin,cx
cmprsloop:
les di,[bx]
mov cx,di
jcxz nocode
dec di
repe scasb
je allspace
inc di
allspace:
inc di
mov byte ptr es:[di],0
mov [bx],di
nocode:
lea bx,[bx+4]
dec curlin
jnz cmprsloop
;
mov cx,lincnt
mov bx,cx
dec bx
shl bx,1
shl bx,1
add bx,offset linptr
reduceloop:
cmp word ptr [bx],0
jne reducend
lea bx,[bx-4]
loop reduceloop
reducend:
cld
mov ax,cx
test ax,ax
ret
;
reducepagebuff endp
;
hdrpgupdate proc
;
cmp hdrprint,YES
jne noheadprt
mov ax,curpage
mov di,hdrpgnum
mov es,hdrlinseg
call inttoasc0
mov word ptr es:[di-05],' -'
noheadprt:
ret
;
hdrpgupdate endp
;
timestamp proc
;
call inttoascs
mov byte ptr es:[di],'/'
inc di
mov al,dh
aam
add ax,'00'
xchg ah,al
stosw
mov byte ptr es:[di],'/'
inc di
mov al,dl
aam
add ax,'00'
xchg ah,al
stosw
mov byte ptr es:[di],' '
inc di
;
mov ax,si
mov al,ah
aam
add ax,'00'
xchg ah,al
stosw
mov byte ptr es:[di],':'
inc di
mov ax,si
aam
add ax,'00'
xchg ah,al
stosw
;
ret
;
timestamp endp
;
nopage proc
;
xor ax,ax
ret
;
nopage endp
;
asmpage proc
;
cld
push ds
pop es
mov di,si
anxtchr:
lodsb
cmp al,0
je alnend
cmp al,0ch
je alnend
cmp al,20h
jbe anxtchr
cmp al,'P'
je anxtchk1
cmp al,'p'
jne alnend
anxtchk1:
lodsb
cmp al,'A'
je anxtchk2
cmp al,'a'
jne alnend
anxtchk2:
lodsb
cmp al,'G'
je anxtchk3
cmp al,'g'
jne alnend
anxtchk3:
lodsb
cmp al,'E'
je anxtchk4
cmp al,'e'
jne alnend
anxtchk4:
lodsb
cmp al,0
je apgchg
cmp al,';'
je apgchg
cmp al,'+'
je apgchg
cmp al,','
je alnend
cmp al,20h
ja short alnend
anxtchk5:
lodsb
cmp al,0
je apgchg
cmp al,20h
jbe anxtchk5
cmp al,'+'
je apgchg
cmp al,';'
je apgchg
cmp al,','
je alnend
cmp al,'0'
jb apgchg
cmp al,'9'
ja apgchg
alnend:
xor ax,ax
ret
;
apgchg:
xor ax,ax
mov cx,1024
repne scasb
sub cx,1024
neg cx
mov si,di
dec si
std
rep movsb
mov byte ptr es:[di],0ch
cld
jmp alnend
;
asmpage endp
;
baspage proc
;
cld
push ds
pop es
mov di,si
;
bnxtchr:
lodsb
cmp al,0
je blnend
cmp al,0ch
je blnend
cmp al,20h
jbe bnxtchr
cmp al,"'"
je bnxtchk0
cmp al,'0'
jb blnend
cmp al,'9'
ja blnend
push di
mov di,si
call asctoint
mov si,di
pop di
jmp bnxtchr
blnend:
xor ax,ax
ret
;
bnxtchk0:
lodsb
cmp al,'@'
jne blnend
lodsb
cmp al,'P'
je bnxtchk1
cmp al,'p'
jne blnend
bnxtchk1:
lodsb
cmp al,'A'
je bnxtchk2
cmp al,'a'
jne blnend
bnxtchk2:
lodsb
cmp al,'G'
je bnxtchk3
cmp al,'g'
jne blnend
bnxtchk3:
lodsb
cmp al,'E'
je bnxtchk4
cmp al,'e'
jne blnend
bnxtchk4:
;
jmp apgchg
;
baspage endp
;
cpage proc
;
push ds
pop es
mov di,si
cld
cmp word ptr [si],'*/'
jne cpg2
cmp word ptr [si+2],'/*'
je cpgchg
cmp word ptr [si+2],'*'
jne cothers
;
cmp feedflag,YES
jne bgnfiln
mov byte ptr [di],0ch
inc di
bgnfiln:
mov byte ptr [di],'/'
inc di
mov al,'*'
mov cx,clmcnt
dec cx
rep stosb
mov byte ptr es:[di],0
jmp short clnend
cpg2:
cmp word ptr [si],'**'
jne cothers
cmp word ptr [si+2],'/'
jne cothers
;
cmp feedflag,YES
jne lstfiln
mov byte ptr [di],0ch
inc di
lstfiln:
mov al,'*'
mov cx,clmcnt
dec cx
rep stosb
mov word ptr [di],'/'
clnend:
mov feedflag,NO
xor ax,ax
ret
cpgchg:
mov feedflag,YES
mov ax,-1
test ax,ax
ret
cothers:
cmp byte ptr [si],0ch
je clnend
cmp feedflag,YES
jne clnend
xor ax,ax
mov cx,1024
repne scasb
sub cx,1024
neg cx
mov si,di
dec si
std
rep movsb
mov byte ptr es:[di],0ch
cld
jmp clnend
;
cpage endp
;
code ends
end